<?php

require_once 'Pipes/FileSystem/Controller/Loader.php';
require_once 'Pipes/FileSystem/Controller/Finder.php';
require_once 'PipesImpl/Config.php';
require_once 'PipesImpl/Route.php';


class Pipes_Framework
{
    private $_config = null;
    
    public function __construct(PipesImpl_Config $config) {
        $this->_config = $config;
    }
    
    public function run(PipesImpl_Route $route) {
        $loader = new Pipes_FileSystem_Controller_Loader(
            new Pipes_FileSystem_Controller_Finder($this->_config)
        );

        $loader->load($route->controller);
        $controller = new $loader->lastLoaded($this->_config);
        return $controller->run($route);
    }
}
